home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / wgdb-42.lha / wgdb-4.2 / gdb / gdb.info-1 < prev    next >
Text File  |  1992-09-11  |  50KB  |  1,347 lines

  1. Info file gdb.info, produced by Makeinfo, -*- Text -*- from input
  2. file gdb-all.texi.
  3.  
  4.    This file documents the GNU debugger GDB.
  5.  
  6.    Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of
  9. this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this
  15. manual under the conditions for verbatim copying, provided also that
  16. the section entitled "GNU General Public License" is included
  17. exactly as in the original, and provided that the entire resulting
  18. derived work is distributed under the terms of a permission notice
  19. identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for
  23. modified versions, except that the section entitled "GNU General
  24. Public License" may be included in a translation approved by the
  25. Free Software Foundation instead of in the original English.
  26.  
  27. 
  28. File: gdb.info,  Node: Top,  Next: Summary,  Prev: (dir),  Up: (dir)
  29.  
  30.    This file describes version 4.2 of GDB, the GNU symbolic debugger.
  31.  
  32. * Menu:
  33.  
  34. * Summary::                     Summary of GDB
  35. * New Features::                New Features in GDB version 4.2
  36. * Sample Session::              A Sample GDB Session
  37. * Invocation::                  Getting In and Out of GDB
  38. * Commands::                    GDB Commands
  39. * Running::                     Running Programs Under GDB
  40. * Stopping::                    Stopping and Continuing
  41. * Stack::                       Examining the Stack
  42. * Source::                      Examining Source Files
  43. * Data::                        Examining Data
  44. * Languages::                   Using GDB with Different Languages
  45. * Symbols::                     Examining the Symbol Table
  46. * Altering::                    Altering Execution
  47. * GDB Files::                   GDB's Files
  48. * Targets::                     Specifying a Debugging Target
  49. * Controlling GDB::             Controlling GDB
  50. * Sequences::                   Canned Sequences of Commands
  51. * Emacs::                       Using GDB under GNU Emacs
  52. * GDB Bugs::                    Reporting Bugs in GDB
  53. * Renamed Commands::
  54. * Installing GDB::              Installing GDB
  55. * Copying::                     GNU GENERAL PUBLIC LICENSE
  56. * Index::                       Index
  57.  
  58.  -- The Detailed Node Listing --
  59.  
  60. Summary of GDB
  61.  
  62. * Free Software::               Free Software
  63. * Contributors::                Contributors to GDB
  64.  
  65. Getting In and Out of GDB
  66.  
  67. * Starting GDB::                Starting GDB
  68. * Leaving GDB::                 Leaving GDB
  69. * Shell Commands::              Shell Commands
  70.  
  71. Starting GDB
  72.  
  73. * File Options::                Choosing Files
  74. * Mode Options::                Choosing Modes
  75.  
  76. GDB Commands
  77.  
  78. * Command Syntax::              Command Syntax
  79. * Help::                        Getting Help
  80.  
  81. Running Programs Under GDB
  82.  
  83. * Compilation::                 Compiling for Debugging
  84. * Starting::                    Starting your Program
  85. * Arguments::                   Your Program's Arguments
  86. * Environment::                 Your Program's Environment
  87. * Working Directory::           Your Program's Working Directory
  88. * Input/Output::                Your Program's Input and Output
  89. * Attach::                      Debugging an Already-Running Process
  90. * Kill Process::                Killing the Child Process
  91.  
  92. Stopping and Continuing
  93.  
  94. * Breakpoints::                 Breakpoints, Watchpoints, and Exceptions
  95. * Continuing and Stepping::     Resuming Execution
  96. * Signals::                     Signals
  97.  
  98. Breakpoints, Watchpoints, and Exceptions
  99.  
  100. * Set Breaks::                  Setting Breakpoints
  101. * Set Watchpoints::             Setting Watchpoints
  102. * Exception Handling::          Breakpoints and Exceptions
  103. * Delete Breaks::               Deleting Breakpoints
  104. * Disabling::                   Disabling Breakpoints
  105. * Conditions::                  Break Conditions
  106. * Break Commands::              Breakpoint Command Lists
  107. * Breakpoint Menus::            Breakpoint Menus
  108. * Error in Breakpoints::        "Cannot insert breakpoints"
  109.  
  110. Examining the Stack
  111.  
  112. * Frames::                      Stack Frames
  113. * Backtrace::                   Backtraces
  114. * Selection::                   Selecting a Frame
  115. * Frame Info::                  Information on a Frame
  116.  
  117. Examining Source Files
  118.  
  119. * List::                        Printing Source Lines
  120. * Search::                      Searching Source Files
  121. * Source Path::                 Specifying Source Directories
  122. * Machine Code::                Source and Machine Code
  123.  
  124. Examining Data
  125.  
  126. * Expressions::                 Expressions
  127. * Variables::                   Program Variables
  128. * Arrays::                      Artificial Arrays
  129. * Output formats::              Output formats
  130. * Memory::                      Examining Memory
  131. * Auto Display::                Automatic Display
  132. * Print Settings::              Print Settings
  133. * Value History::               Value History
  134. * Convenience Vars::            Convenience Variables
  135. * Registers::                   Registers
  136. * Floating Point Hardware::     Floating Point Hardware
  137.  
  138. Using GDB with Different Languages
  139.  
  140. * Setting::                     Switching between source languages
  141. * Show::                        Displaying the language
  142. * Checks::                      Type and Range checks
  143. * Support::                     Supported languages
  144.  
  145. Switching between source languages
  146.  
  147. * Manually::                    Setting the working language manually
  148. * Automatically::               Having GDB infer the source language
  149.  
  150. Type and range Checking
  151.  
  152. * Type Checking::               An overview of type checking
  153. * Range Checking::              An overview of range checking
  154.  
  155. Supported Languages
  156.  
  157. * C::                           C and C++
  158. * Modula-2::                    Modula-2
  159.  
  160. C and C++
  161.  
  162. * C Operators::                 C and C++ Operators
  163. * C Constants::                 C and C++ Constants
  164. * Cplusplus expressions::       C++ Expressions
  165. * C Defaults::                  Default settings for C and C++
  166. * C Checks::                    C and C++ Type and Range Checks
  167. * Debugging C::                 GDB and C
  168. * Debugging C plus plus::       Special features for C++
  169.  
  170. Modula-2
  171.  
  172. * M2 Operators::                Built-in operators
  173. * Builtin Func/Proc::           Built-in Functions and Procedures
  174. * M2 Constants::                Modula-2 Constants
  175. * M2 Defaults::                 Default settings for Modula-2
  176. * Deviations::                  Deviations from standard Modula-2
  177. * M2 Checks::                   Modula-2 Type and Range Checks
  178. * M2 Scope::                    The scope operators `::' and `.'
  179. * GDB/M2::                      GDB and Modula-2
  180.  
  181. Altering Execution
  182.  
  183. * Assignment::                  Assignment to Variables
  184. * Jumping::                     Continuing at a Different Address
  185. * Signaling::                   Giving the Program a Signal
  186. * Returning::                   Returning from a Function
  187. * Calling::                     Calling your Program's Functions
  188. * Patching::                    Patching your Program
  189.  
  190. GDB's Files
  191.  
  192. * Files::                       Commands to Specify Files
  193. * Symbol Errors::               Errors Reading Symbol Files
  194.  
  195. Specifying a Debugging Target
  196.  
  197. * Active Targets::              Active Targets
  198. * Target Commands::             Commands for Managing Targets
  199. * Remote::                      Remote Debugging
  200.  
  201. Remote Debugging
  202.  
  203. * i960-Nindy Remote::           GDB with a Remote i960 (Nindy)
  204. * EB29K Remote::                GDB with a Remote EB29K
  205. * VxWorks Remote::              GDB and VxWorks
  206.  
  207. GDB with a Remote i960 (Nindy)
  208.  
  209. * Nindy Startup::               Startup with Nindy
  210. * Nindy Options::               Options for Nindy
  211. * Nindy reset::                 Nindy Reset Command
  212.  
  213. GDB with a Remote EB29K
  214.  
  215. * Comms (EB29K)::               Communications Setup
  216. * gdb-EB29K::                   EB29K cross-debugging
  217. * Remote Log::                  Remote Log
  218.  
  219. GDB and VxWorks
  220.  
  221. * VxWorks connection::          Connecting to VxWorks
  222. * VxWorks download::            VxWorks Download
  223. * VxWorks attach::              Running Tasks
  224.  
  225. Controlling GDB
  226.  
  227. * Prompt::                      Prompt
  228. * Editing::                     Command Editing
  229. * History::                     Command History
  230. * Screen Size::                 Screen Size
  231. * Numbers::                     Numbers
  232. * Messages/Warnings::           Optional Warnings and Messages
  233.  
  234. Canned Sequences of Commands
  235.  
  236. * Define::                      User-Defined Commands
  237. * Command Files::               Command Files
  238. * Output::                      Commands for Controlled Output
  239.  
  240. Reporting Bugs in GDB
  241.  
  242. * Bug Criteria::                Have You Found a Bug?
  243. * Bug Reporting::               How to Report Bugs
  244.  
  245. Installing GDB
  246.  
  247. * Subdirectories::              Configuration subdirectories
  248. * Config Names::                Specifying names for hosts and targets
  249. * configure Options::           Summary of options for configure
  250. * Formatting Documentation::    How to format and print GDB documentation
  251.  
  252. 
  253. File: gdb.info,  Node: Summary,  Next: New Features,  Prev: Top,  Up: Top
  254.  
  255. Summary of GDB
  256. **************
  257.  
  258.    The purpose of a debugger such as GDB is to allow you to see what
  259. is going on "inside" another program while it executes--or what
  260. another program was doing at the moment it crashed.
  261.  
  262.    GDB can do four main kinds of things (plus other things in support
  263. of these) to help you catch bugs in the act:
  264.  
  265.    * Start your program, specifying anything that might affect its
  266.      behavior.
  267.  
  268.    * Make your program stop on specified conditions.
  269.  
  270.    * Examine what has happened, when your program has stopped.
  271.  
  272.    * Change things in your program, so you can experiment with
  273.      correcting the effects of one bug and go on to learn about
  274.      another.
  275.  
  276.    You can use GDB to debug programs written in C, C++, and Modula-2.
  277. Fortran support will be added when a GNU Fortran compiler is ready.
  278.  
  279. * Menu:
  280.  
  281. * Free Software::               Free Software
  282. * Contributors::                Contributors to GDB
  283.  
  284. 
  285. File: gdb.info,  Node: Free Software,  Next: Contributors,  Prev: Summary,  Up: Summary
  286.  
  287. Free Software
  288. =============
  289.  
  290.    GDB is "free software", protected by the GNU General Public
  291. License (GPL).  The GPL gives you the freedom to copy or adapt a
  292. licensed program--but every person getting a copy also gets with it
  293. the freedom to modify that copy (which means that they must get
  294. access to the source code), and the freedom to distribute further
  295. copies.  Typical software companies use copyrights to limit your
  296. freedoms; the Free Software Foundation uses the GPL to preserve
  297. these freedoms.
  298.  
  299.    Fundamentally, the General Public License is a license which says
  300. that you have these freedoms and that you can't take these freedoms
  301. away from anyone else.
  302.  
  303.    For full details, *note Copying::..
  304.  
  305. 
  306. File: gdb.info,  Node: Contributors,  Prev: Free Software,  Up: Summary
  307.  
  308. Contributors to GDB
  309. ===================
  310.  
  311.    Richard Stallman was the original author of GDB, and of many other
  312. GNU programs.  Many others have contributed to its development. 
  313. This section attempts to credit major contributors.  One of the
  314. virtues of free software is that everyone is free to contribute to
  315. it; with regret, we cannot actually acknowledge everyone here.  The
  316. file `ChangeLog' in the GDB distribution approximates a blow-by-blow
  317. account.
  318.  
  319.    Changes much prior to version 2.0 are lost in the mists of time.
  320.  
  321.      *Plea:* Additions to this section are particularly welcome.  If
  322.      you or your friends (or enemies; let's be evenhanded) have been
  323.      unfairly omitted from this list, we would like to add your names!
  324.  
  325.    So that they may not regard their long labor as thankless, we
  326. particularly thank those who shepherded GDB through major releases:
  327. John Gilmore (releases 4.2, 4.1, 4.0); Jim Kingdon (releases 3.9,
  328. 3.5, 3.4, 3.3); and Randy Smith (releases 3.2, 3.1, 3.0).  As major
  329. maintainer of GDB for some period, each contributed significantly to
  330. the structure, stability, and capabilities of the entire debugger.
  331.  
  332.    Richard Stallman, assisted at various times by Pete TerMaat, Chris
  333. Hanson, and Richard Mlynarik, handled releases through 2.8.
  334.  
  335.    Michael Tiemann is the author of most of the GNU C++ support in
  336. GDB, with significant additional contributions from Per Bothner. 
  337. James Clark wrote the GNU C++ demangler.  Early work on C++ was by
  338. Peter TerMaat (who also did much general update work leading to
  339. release 3.0).
  340.  
  341.    GDB 4.2 uses the BFD subroutine library to examine multiple
  342. object-file formats; BFD was a joint project of V. Gumby
  343. Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
  344.  
  345.    David Johnson wrote the original COFF support; Pace Willison did
  346. the original support for encapsulated COFF.
  347.  
  348.    Adam de Boor and Bradley Davis contributed the ISI Optimum V
  349. support.  Per Bothner, Noboyuki Hikichi, and Alessandro Forin
  350. contributed MIPS support.  Jean-Daniel Fekete contributed Sun 386i
  351. support.  Chris Hanson improved the HP9000 support.  Noboyuki
  352. Hikichi
  353. and Tomoyuki Hasei contributed Sony/News OS 3 support.  David
  354. Johnson contributed Encore Umax support.  Jyrki Kuoppala contributed
  355. Altos 3068 support.  Keith Packard contributed NS32K support.  Doug
  356. Rabson contributed Acorn Risc Machine support.  Chris Smith
  357. contributed Convex support (and Fortran debugging).  Jonathan Stone
  358. contributed Pyramid support.  Michael Tiemann contributed SPARC
  359. support.  Tim Tucker contributed support for the Gould NP1 and Gould
  360. Powernode.  Pace Willison contributed Intel 386 support.  Jay
  361. Vosburgh contributed Symmetry support.
  362.  
  363.    Rich Schaefer and Peter Schauer helped with support of SunOS
  364. shared libraries.
  365.  
  366.    Jay Fenlason and Roland McGrath ensured that GDB and GAS agree
  367. about several machine instruction sets.
  368.  
  369.    Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped
  370. develop remote debugging.  Intel Corporation and Wind River Systems
  371. contributed remote debugging modules for their products.
  372.  
  373.    Brian Fox is the author of the readline libraries providing
  374. command-line editing and command history.
  375.  
  376.    Andrew Beers of SUNY Buffalo wrote the language-switching code and
  377. the Modula-2 support, and contributed the Languages chapter of this
  378. manual.
  379.  
  380. 
  381. File: gdb.info,  Node: New Features,  Next: Sample Session,  Prev: Summary,  Up: Top
  382.  
  383. New Features since GDB version 3.5
  384. **********************************
  385.  
  386. *Targets*
  387.      Using the new command `target', you can select at runtime
  388.      whether you are debugging local files, local processes,
  389.      standalone systems over a serial port, realtime systems over a
  390.      TCP/IP connection, etc.  The command `load' can download
  391.      programs into a remote system.  Serial stubs are available for
  392.      Motorola 680x0 and Intel 80386 remote systems; GDB also
  393.      supports debugging realtime processes running under VxWorks,
  394.      using SunRPC Remote Procedure Calls over TCP/IP to talk to a
  395.      debugger stub on the target system.  Internally, GDB now uses a
  396.      function vector to mediate access to different targets; if you
  397.      need to add your own support for a remote protocol, this makes
  398.      it much easier.
  399.  
  400. *Watchpoints*
  401.      GDB now sports watchpoints as well as breakpoints.  You can use
  402.      a watchpoint to stop execution whenever the value of an
  403.      expression changes, without having to predict a particular
  404.      place in your program where this may happen.
  405.  
  406. *Wide Output*
  407.      Commands that issue wide output now insert newlines at places
  408.      designed to make the output more readable.
  409.  
  410. *Object Code Formats*
  411.      GDB uses a new library called the Binary File Descriptor (BFD)
  412.      Library to permit it to switch dynamically, without
  413.      reconfiguration or recompilation, between different object-file
  414.      formats.  Formats currently supported are COFF, a.out, and the
  415.      Intel 960 b.out; files may be read as .o's, archive libraries,
  416.      or core dumps.  BFD is available as a subroutine library so
  417.      that other programs may take advantage of it, and the other GNU
  418.      binary utilities are being converted to use it.
  419.  
  420. *Configuration and Ports*
  421.      Compile-time configuration (to select a particular architecture
  422.      and operating system) is much easier.  The script `configure'
  423.      now allows you to configure GDB as either a native debugger or
  424.      a cross-debugger. *Note Installing GDB:: for details on how to
  425.      configure and on what architectures are now available.
  426.  
  427. *Interaction*
  428.      The user interface to GDB's control variables has been
  429.      simplified and consolidated in two commands, `set' and `show'. 
  430.     
  431.      Output lines are now broken at readable places, rather than
  432.      overflowing onto the next line.  You can suppress output of
  433.      machine-level addresses, displaying only source language
  434.      information.
  435.  
  436. *C++*
  437.      GDB now supports C++ multiple inheritance (if used with a GCC
  438.      version 2 compiler), and also has limited support for C++
  439.      exception handling, with the commands `catch' and `info catch':
  440.      GDB can break when an exception is raised, before the stack is
  441.      peeled back to the exception handler's context.
  442.  
  443. *Modula-2*
  444.      GDB now has preliminary support for the GNU Modula-2 compiler,
  445.      currently under development at the State University of New York
  446.      at Buffalo.  Coordinated development of both GDB and the GNU
  447.      Modula-2 compiler will continue through the fall of 1991 and
  448.      into 1992.  Other Modula-2 compilers are currently not
  449.     
  450.      supported, and attempting to debug programs compiled with them
  451.      will likely result in an error as the symbol table of the
  452.      executable is read in.
  453.  
  454. *Command Rationalization*
  455.      Many GDB commands have been renamed to make them easier to
  456.      remember and use.  In particular, the subcommands of `info' and
  457.      `show'/`set' are grouped to make the former refer to the state
  458.      of your program, and the latter refer to the state of GDB itself.
  459.      *Note Renamed Commands::, for details on what commands were
  460.      renamed.
  461.  
  462. *Shared Libraries*
  463.      GDB 4.2 can debug programs and core files that use SunOS shared
  464.      libraries.
  465.  
  466. *Reference Card*
  467.      GDB 4.2 has a reference card; *Note Formatting Documentation::
  468.      for instructions on printing it.
  469.  
  470. *Work in Progress*
  471.      Kernel debugging for BSD and Mach systems; Tahoe and HPPA
  472.      architecture support.
  473.  
  474. 
  475. File: gdb.info,  Node: Sample Session,  Next: Invocation,  Prev: New Features,  Up: Top
  476.  
  477. A Sample GDB Session
  478. ********************
  479.  
  480.    You can use this manual at your leisure to read all about GDB. 
  481. However, a handful of commands are enough to get started using the
  482. debugger.  This chapter illustrates these commands.
  483.  
  484.    One of the preliminary versions of GNU `m4' (a generic macro
  485. processor) exhibits the following bug: sometimes, when we change its
  486. quote strings from the default, the commands used to capture one
  487. macro's definition in another stop working.  In the following short
  488. `m4' session, we define a macro `foo' which expands to `0000'; we
  489. then
  490. use the `m4' builtin `defn' to define `bar' as the same thing. 
  491. However, when we change the open quote string to `<QUOTE>' and the
  492. close quote string to `<UNQUOTE>', the same procedure fails to
  493. define a new synonym `baz':
  494.  
  495.      $ cd gnu/m4
  496.      $ ./m4
  497.      define(foo,0000)
  498.      
  499.      foo
  500.      0000
  501.      define(bar,defn(`foo'))
  502.      
  503.      bar
  504.      0000
  505.      changequote(<QUOTE>,<UNQUOTE>)
  506.      
  507.      define(baz,defn(<QUOTE>foo<UNQUOTE>))
  508.      baz
  509.      C-d
  510.      m4: End of input: 0: fatal error: EOF in string
  511.  
  512. Let's use GDB to try to see what's going on.
  513.  
  514.      $ gdb m4
  515.      GDB is free software and you are welcome to distribute copies of it
  516.       under certain conditions; type "show copying" to see the conditions.
  517.      There is absolutely no warranty for GDB; type "show warranty" for details.
  518.      GDB 4.2, Copyright 1991 Free Software Foundation, Inc...
  519.      (gdb)
  520.  
  521. GDB reads only enough symbol data to know where to find the rest when
  522. needed; as a result, the first prompt comes up very quickly.  We
  523. then tell GDB to use a narrower display width than usual, so that
  524. examples will fit in this manual.
  525.  
  526.      (gdb) set width 70
  527.  
  528. Let's see how the `m4' builtin `changequote' works.  Having looked at
  529. the source, we know the relevant subroutine is `m4_changequote', so
  530. we set a breakpoint there with GDB's `break' command.
  531.  
  532.      (gdb) break m4_changequote
  533.      Breakpoint 1 at 0x62f4: file builtin.c, line 879.
  534.  
  535. Using the `run' command, we start `m4' running under GDB control; as
  536. long as control does not reach the `m4_changequote' subroutine, the
  537. program runs as usual:
  538.  
  539.      (gdb) run
  540.      Starting program: /work/Editorial/gdb/gnu/m4/m4
  541.      define(foo,0000)
  542.      
  543.      foo
  544.      0000
  545.  
  546. To trigger the breakpoint, we call `changequote'.  GDB suspends
  547. execution of `m4', displaying information about the context where it
  548. stops.
  549.  
  550.      changequote(<QUOTE>,<UNQUOTE>)
  551.      
  552.      Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) at builtin.c:879
  553.      879         if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3))
  554.  
  555. Now we use the command `n' (`next') to advance execution to the next
  556. line of the current function.
  557.  
  558.      (gdb) n
  559.      882         set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1]) : nil,
  560.  
  561. `set_quotes' looks like a promising subroutine.  We can go into it by
  562. using the command `s' (`step') instead of `next'.  `step' goes to
  563. the next line to be executed in *any* subroutine, so it steps into
  564. `set_quotes'.
  565.  
  566.      (gdb) s
  567.      set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  568.          at input.c:530
  569.      530         if (lquote != def_lquote)
  570.  
  571. The summary display showing the subroutine where `m4' is now
  572. suspended (and its arguments) is called a stack frame display.  We
  573. can use the `backtrace' command (which can also be spelled `bt'), to
  574. see where we are in the stack: it displays a stack frame for each
  575. active subroutine.
  576.  
  577.      (gdb) bt
  578.      #0  set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  579.          at input.c:530
  580.      #1  0x6344 in m4_changequote (argc=3, argv=0x33c70) at builtin.c:882
  581.      #2  0x8174 in expand_macro (sym=0x33320) at macro.c:242
  582.      #3  0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
  583.          at macro.c:71
  584.      #4  0x79dc in expand_input () at macro.c:40
  585.      #5  0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
  586.  
  587. Let's step through a few more lines to see what happens.  The first
  588. two times, we can use `s'; the next two times we use `n' to avoid
  589. falling into the `xstrdup' subroutine.
  590.  
  591.      (gdb) s
  592.      0x3b5c  532         if (rquote != def_rquote)
  593.      (gdb) s
  594.      0x3b80  535         lquote = (lq == nil || *lq == '\0') ? def_lquote :\
  595.       xstrdup(lq);
  596.      (gdb) n
  597.      536         rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\
  598.      (rq);
  599.      (gdb) n
  600.      538         len_lquote = strlen(rquote);
  601.  
  602. The last line displayed looks a little odd; let's examine the
  603. variables `lquote' and `rquote' to see if they are in fact the new
  604. left and right quotes we specified.  We can use the command `p'
  605. (`print') to see their values.
  606.  
  607.      (gdb) p lquote
  608.      $1 = 0x35d40 "<QUOTE>"
  609.      (gdb) p rquote
  610.      $2 = 0x35d50 "<UNQUOTE>"
  611.  
  612. `lquote' and `rquote' are indeed the new left and right quotes. 
  613. Let's look at some context; we can display ten lines of source
  614. surrounding the current line, with the `l' (`list') command.
  615.  
  616.      (gdb) l
  617.      533             xfree(rquote);
  618.      534
  619.      535         lquote = (lq == nil || *lq == '\0') ? def_lquote : xstrdup\
  620.      (lq);
  621.      536         rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\
  622.      (rq);
  623.      537
  624.      538         len_lquote = strlen(rquote);
  625.      539         len_rquote = strlen(lquote);
  626.      540     }
  627.      541
  628.      542     void
  629.  
  630. Let's step past the two lines that set `len_lquote' and `len_rquote',
  631. and then examine the values of those variables.
  632.  
  633.      (gdb) n
  634.      539         len_rquote = strlen(lquote);
  635.      (gdb) n
  636.      540     }
  637.      (gdb) p len_lquote
  638.      $3 = 9
  639.      (gdb) p len_rquote
  640.      $4 = 7
  641.  
  642. That certainly looks wrong, assuming `len_lquote' and `len_rquote'
  643. are
  644. meant to be the lengths of `lquote' and `rquote' respectively. 
  645. Let's try setting them to better values.  We can use the `p' command
  646. for this, since it'll print the value of any expression--and that
  647. expression can include subroutine calls and assignments.
  648.  
  649.      (gdb) p len_lquote=strlen(lquote)
  650.      $5 = 7
  651.      (gdb) p len_rquote=strlen(rquote)
  652.      $6 = 9
  653.  
  654. Let's see if that fixes the problem of using the new quotes with the
  655. `m4' built-in `defn'.  We can allow `m4' to continue executing with
  656. the `c' (`continue') command, and then try the example that caused
  657. trouble initially:
  658.  
  659.      (gdb) c
  660.      Continuing.
  661.      
  662.      define(baz,defn(<QUOTE>foo<UNQUOTE>))
  663.      
  664.      baz
  665.      0000
  666.  
  667. Success!  The new quotes now work just as well as the default ones. 
  668. The problem seems to have been just the two typos defining the wrong
  669. lengths.  We'll let `m4' exit by giving it an EOF as input.
  670.  
  671.      C-d
  672.      Program exited normally.
  673.  
  674. The message `Program exited normally.' is from GDB; it indicates `m4'
  675. has finished executing.  We can end our GDB session with the GDB
  676. `quit' command.
  677.  
  678.      (gdb) quit
  679.  
  680. 
  681. File: gdb.info,  Node: Invocation,  Next: Commands,  Prev: Sample Session,  Up: Top
  682.  
  683. Getting In and Out of GDB
  684. *************************
  685.  
  686. * Menu:
  687.  
  688. * Starting GDB::                Starting GDB
  689. * Leaving GDB::                 Leaving GDB
  690. * Shell Commands::              Shell Commands
  691.  
  692. 
  693. File: gdb.info,  Node: Starting GDB,  Next: Leaving GDB,  Prev: Invocation,  Up: Invocation
  694.  
  695. Starting GDB
  696. ============
  697.  
  698.    GDB is invoked with the shell command `gdb'.  Once started, it
  699. reads commands from the terminal until you tell it to exit.
  700.  
  701.    You can run `gdb' with no arguments or options; but the most usual
  702. way to start GDB is with one argument or two, specifying an
  703. executable program as the argument:
  704.  
  705.      gdb program
  706.  
  707. You can also start with both an executable program and a core file
  708. specified:
  709.  
  710.      gdb program core
  711.  
  712.    You can, instead, specify a process ID as a second argument, if
  713. you want to debug a running process:
  714.  
  715.      gdb program 1234
  716.  
  717. would attach GDB to process `1234' (unless you also have a file named
  718. `1234'; GDB does check for a core file first).
  719.  
  720. You can further control how GDB starts up by using command-line
  721. options.  GDB itself can remind you of the options available:
  722.  
  723.      gdb -help
  724.  
  725. will display all available options and briefly describe their use
  726. (`gdb -h' is a shorter equivalent).
  727.  
  728.    All options and command line arguments you give are processed in
  729. sequential order.  The order makes a difference when the `-x' option
  730. is used.
  731.  
  732. * Menu:
  733.  
  734. * File Options::                Choosing Files
  735. * Mode Options::                Choosing Modes
  736.  
  737. 
  738. File: gdb.info,  Node: File Options,  Next: Mode Options,  Prev: Starting GDB,  Up: Starting GDB
  739.  
  740. Choosing Files
  741. --------------
  742.  
  743.    As shown above, any arguments other than options specify an
  744. executable file and core file; that is, the first argument
  745. encountered with no associated option flag is equivalent to a `-se'
  746. option, and the second, if any, is equivalent to a `-c' option. 
  747. Many options have both long and short forms; both are shown here. 
  748. The long forms are also recognized if you truncate them, so long as
  749. enough of the option is present to be unambiguous.  (If you prefer,
  750. you can flag option arguments with `+' rather than `-', though we
  751. illustrate the more usual convention.)
  752.  
  753. `-symbols=FILE'
  754. `-s FILE'
  755.      Read symbol table from file FILE.
  756.  
  757. `-exec=FILE'
  758. `-e FILE'
  759.      Use file FILE as the executable file to execute when
  760.      appropriate, and for examining pure data in conjunction with a
  761.      core dump.
  762.  
  763. `-se=FILE'
  764.      Read symbol table from file FILE and use it as the executable
  765.      file.
  766.  
  767. `-core=FILE'
  768. `-c FILE'
  769.      Use file FILE as a core dump to examine.
  770.  
  771. `-command=FILE'
  772. `-x FILE'
  773.      Execute GDB commands from file FILE.  *Note Command Files::.
  774.  
  775. `-directory=DIRECTORY'
  776. `-d DIRECTORY'
  777.      Add DIRECTORY to the path to search for source files.
  778.  
  779. 
  780. File: gdb.info,  Node: Mode Options,  Prev: File Options,  Up: Starting GDB
  781.  
  782. Choosing Modes
  783. --------------
  784.  
  785. `-nx'
  786. `-n'
  787.      Do not execute commands from any `.gdbinit' initialization files.
  788.      Normally, the commands in these files are executed after all
  789.      the command options and arguments have been processed.  *Note
  790.      Command Files::.
  791.  
  792. `-quiet'
  793. `-q'
  794.      "Quiet".  Do not print the introductory and copyright messages. 
  795.      These messages are also suppressed in batch mode.
  796.  
  797. `-batch'
  798.      Run in batch mode.  Exit with status `0' after processing all
  799.      the command files specified with `-x' (and `.gdbinit', if not
  800.      inhibited).  Exit with nonzero status if an error occurs in
  801.      executing the GDB commands in the command files.
  802.  
  803.      Batch mode may be useful for running GDB as a filter, for
  804.      example to download and run a program on another computer; in
  805.      order to make this more useful, the message
  806.  
  807.           Program exited normally.
  808.  
  809.      (which is ordinarily issued whenever a program running under GDB
  810.      control terminates) is not issued when running in batch mode.
  811.  
  812. `-cd=DIRECTORY'
  813.      Run GDB using DIRECTORY as its working directory, instead of the
  814.      current directory.
  815.  
  816. `-fullname'
  817. `-f'
  818.      Emacs sets this option when it runs GDB as a subprocess.  It
  819.      tells GDB to output the full file name and line number in a
  820.      standard, recognizable fashion each time a stack frame is
  821.      displayed (which includes each time the program stops).  This
  822.      recognizable format looks like two `\032' characters, followed
  823.      by the file name, line number and character position separated
  824.      by colons, and a newline.  The Emacs-to-GDB interface program
  825.      uses the two `\032' characters as a signal to display the
  826.      source code for the frame.
  827.  
  828. `-b BPS'
  829.      Set the line speed (baud rate or bits per second) of any serial
  830.      interface used by GDB for remote debugging.
  831.  
  832. `-tty=DEVICE'
  833.      Run using DEVICE for your program's standard input and output.
  834.  
  835. 
  836. File: gdb.info,  Node: Leaving GDB,  Next: Shell Commands,  Prev: Starting GDB,  Up: Invocation
  837.  
  838. Leaving GDB
  839. ===========
  840.  
  841. `quit'
  842.      To exit GDB, use the `quit' command (abbreviated `q'), or type
  843.      an end-of-file character (usually `C-d').
  844.  
  845.    An interrupt (often `C-c') will not exit from GDB, but rather will
  846. terminate the action of any GDB command that is in progress and
  847. return to GDB command level.  It is safe to type the interrupt
  848. character at any time because GDB does not allow it to take effect
  849. until a time when it is safe.
  850.  
  851.    If you've been using GDB to control an attached process or device,
  852. you can release it with the `detach' command; *note Attach::..
  853.  
  854. 
  855. File: gdb.info,  Node: Shell Commands,  Prev: Leaving GDB,  Up: Invocation
  856.  
  857. Shell Commands
  858. ==============
  859.  
  860.    If you need to execute occasional shell commands during your
  861. debugging session, there's no need to leave or suspend GDB; you can
  862. just use the `shell' command.
  863.  
  864. `shell COMMAND STRING'
  865.      Directs GDB to invoke an inferior shell to execute COMMAND
  866.      STRING.  If it exists, the environment variable `SHELL' is used
  867.      for the name of the shell to run.  Otherwise GDB uses `/bin/sh'.
  868.  
  869.    The utility `make' is often needed in development environments. 
  870. You don't have to use the `shell' command for this purpose in GDB:
  871.  
  872. `make MAKE-ARGS'
  873.      Causes GDB to execute an inferior `make' program with the
  874.      specified arguments.  This is equivalent to `shell make
  875.      MAKE-ARGS'.
  876.  
  877. 
  878. File: gdb.info,  Node: Commands,  Next: Running,  Prev: Invocation,  Up: Top
  879.  
  880. GDB Commands
  881. ************
  882.  
  883. * Menu:
  884.  
  885. * Command Syntax::              Command Syntax
  886. * Help::                        Getting Help
  887.  
  888. 
  889. File: gdb.info,  Node: Command Syntax,  Next: Help,  Prev: Commands,  Up: Commands
  890.  
  891. Command Syntax
  892. ==============
  893.  
  894.    A GDB command is a single line of input.  There is no limit on how
  895. long it can be.  It starts with a command name, which is followed by
  896. arguments
  897. whose meaning depends on the command name.  For example, the command
  898. `step' accepts an argument which is the number of times to step, as
  899. in `step 5'.  You can also use the `step' command with no arguments.
  900. Some command names do not allow any arguments.
  901.  
  902.    GDB command names may always be truncated if that abbreviation is
  903. unambiguous.  Other possible command abbreviations are listed in the
  904. documentation for individual commands.  In some cases, even
  905. ambiguous abbreviations are allowed; for example, `s' is specially
  906. defined as equivalent to `step' even though there are other commands
  907. whose names start with `s'.  You can test abbreviations by using
  908. them as arguments to the `help' command.
  909.  
  910.    A blank line as input to GDB (typing just RET) means to repeat the
  911. previous command. Certain commands (for example, `run') will not
  912. repeat this way; these are commands for which unintentional
  913. repetition might cause trouble and which you are unlikely to want to
  914. repeat.
  915.  
  916.    The `list' and `x' commands, when you repeat them with RET,
  917. construct new arguments rather than repeating exactly as typed. 
  918. This permits easy scanning of source or memory.
  919.  
  920.    GDB can also use RET in another way: to partition lengthy output,
  921. in a way similar to the common utility `more' (*note Screen
  922. Size::.).  Since it's easy to press one RET too many in this
  923. situation, GDB disables command repetition after any command that
  924. generates this sort of display.
  925.  
  926.    A line of input starting with `#' is a comment; it does nothing. 
  927. This is useful mainly in command files (*Note Command Files::).
  928.  
  929. 
  930. File: gdb.info,  Node: Help,  Prev: Command Syntax,  Up: Commands
  931.  
  932. Getting Help
  933. ============
  934.  
  935.    You can always ask GDB itself for information on its commands,
  936. using the command `help'.
  937.  
  938. `help'
  939. `h'
  940.      You can use `help' (abbreviated `h') with no arguments to
  941.      display a short list of named classes of commands:
  942.  
  943.           (gdb) help
  944.           List of classes of commands:
  945.           
  946.           running -- Running the program
  947.           stack -- Examining the stack
  948.           data -- Examining data
  949.           breakpoints -- Making program stop at certain points
  950.           files -- Specifying and examining files
  951.           status -- Status inquiries
  952.           support -- Support facilities
  953.           user-defined -- User-defined commands
  954.           aliases -- Aliases of other commands
  955.           obscure -- Obscure features
  956.           
  957.           Type "help" followed by a class name for a list of commands in that class.
  958.           Type "help" followed by command name for full documentation.
  959.           Command name abbreviations are allowed if unambiguous.
  960.           (gdb)
  961.  
  962. `help CLASS'
  963.      Using one of the general help classes as an argument, you can
  964.      get a list of the individual commands in that class.  For
  965.      example, here is the help display for the class `status':
  966.  
  967.           (gdb) help status
  968.           Status inquiries.
  969.           
  970.           List of commands:
  971.           
  972.           show -- Generic command for showing things set with "set"
  973.           info -- Generic command for printing status
  974.           
  975.           Type "help" followed by command name for full documentation.
  976.           Command name abbreviations are allowed if unambiguous.
  977.           (gdb)
  978.  
  979. `help COMMAND'
  980.      With a command name as `help' argument, GDB will display a short
  981.      paragraph on how to use that command.
  982.  
  983.    In addition to `help', you can use the GDB commands `info' and
  984. `show' to inquire about the state of your program, or the state of
  985. GDB itself.  Each command supports many topics of inquiry; this
  986. manual introduces each of them in the appropriate context.  The
  987. listings under `info' and under `show' in the Index point to all the
  988. sub-commands.
  989.  
  990. `info'
  991.      This command (abbreviated `i') is for describing the state of
  992.      your program; for example, it can list the arguments given to
  993.      your program (`info args'), the registers currently in use
  994.      (`info registers'), or the breakpoints you've set (`info
  995.      breakpoints').  You can get a complete list of the `info'
  996.      sub-commands with `help info'.
  997.  
  998. `show'
  999.      In contrast, `show' is for describing the state of GDB itself. 
  1000.      You can change most of the things you can `show', by using the
  1001.      related command `set'; for example, you can control what number
  1002.      system is used for displays with `set radix', or simply inquire
  1003.      which is currently in use with `show radix'.
  1004.  
  1005.      To display all the settable parameters and their current values,
  1006.      you can use `show' with no arguments; you may also use `info
  1007.      set'.  Both commands produce the same display.
  1008.  
  1009.    Here are three miscellaneous `show' subcommands, all of which are
  1010. exceptional in lacking corresponding `set' commands:
  1011.  
  1012. `show version'
  1013.      Show what version of GDB is running.  You should include this
  1014.      information in GDB bug-reports.  If multiple versions of GDB
  1015.      are in use at your site, you may occasionally want to make sure
  1016.      what version of GDB you're running; as GDB evolves, new
  1017.      commands are introduced, and old ones may wither away.  The
  1018.      version number is also announced when you start GDB with no
  1019.      arguments.
  1020.  
  1021. `show copying'
  1022.      Display information about permission for copying GDB.
  1023.  
  1024. `show warranty'
  1025.      Display the GNU "NO WARRANTY" statement.
  1026.  
  1027. 
  1028. File: gdb.info,  Node: Running,  Next: Stopping,  Prev: Commands,  Up: Top
  1029.  
  1030. Running Programs Under GDB
  1031. **************************
  1032.  
  1033. * Menu:
  1034.  
  1035. * Compilation::                 Compiling for Debugging
  1036. * Starting::                    Starting your Program
  1037. * Arguments::                   Your Program's Arguments
  1038. * Environment::                 Your Program's Environment
  1039. * Working Directory::           Your Program's Working Directory
  1040. * Input/Output::                Your Program's Input and Output
  1041. * Attach::                      Debugging an Already-Running Process
  1042. * Kill Process::                Killing the Child Process
  1043.  
  1044. 
  1045. File: gdb.info,  Node: Compilation,  Next: Starting,  Prev: Running,  Up: Running
  1046.  
  1047. Compiling for Debugging
  1048. =======================
  1049.  
  1050.    In order to debug a program effectively, you need to generate
  1051. debugging information when you compile it.  This debugging
  1052. information is stored in the object file; it describes the data type
  1053. of each variable or function and the correspondence between source
  1054. line numbers and addresses in the executable code.
  1055.  
  1056.    To request debugging information, specify the `-g' option when you
  1057. run the compiler.
  1058.  
  1059.    Many C compilers are unable to handle the `-g' and `-O' options
  1060. together.  Using those compilers, you cannot generate optimized
  1061. executables containing debugging information.
  1062.  
  1063.    The GNU C compiler supports `-g' with or without `-O', making it
  1064. possible to debug optimized code.  We recommend that you *always*
  1065. use `-g' whenever you compile a program.  You may think the program
  1066. is correct, but there's no sense in pushing your luck.
  1067.  
  1068.    Some things do not work as well with `-g -O' as with just `-g',
  1069. particularly on machines with instruction scheduling.  If in doubt,
  1070. recompile with `-g' alone, and if this fixes the problem, please
  1071. report it as a bug (including a test case!).
  1072.  
  1073.    Older versions of the GNU C compiler permitted a variant option
  1074. `-gg' for debugging information.  GDB no longer supports this
  1075. format; if your GNU C compiler has this option, do not use it.
  1076.  
  1077. 
  1078. File: gdb.info,  Node: Starting,  Next: Arguments,  Prev: Compilation,  Up: Running
  1079.  
  1080. Starting your Program
  1081. =====================
  1082.  
  1083. `run'
  1084. `r'
  1085.      Use the `run' command to start your program under GDB.  You must
  1086.      first specify the program name (except on VxWorks) with an
  1087.      argument to GDB (*note Invocation::.), or using the `file' or
  1088.      `exec-file' command (*note Files::.).
  1089.  
  1090.    On targets that support processes, `run' creates an inferior
  1091. process and makes that process run your program.  On other targets,
  1092. `run' jumps to the start of the program.
  1093.  
  1094.    The execution of a program is affected by certain information it
  1095. receives from its superior.  GDB provides ways to specify this
  1096. information, which you must do before starting the program.  (You
  1097. can change it after starting the program, but such changes will only
  1098. affect the program the next time you start it.)  This information
  1099. may be divided into four categories:
  1100.  
  1101. The arguments.
  1102.      You specify the arguments to give your program as the arguments
  1103.      of the `run' command.  If a shell is available on your target,
  1104.      the shell is used to pass the arguments, so that you may use
  1105.      normal conventions (such as wildcard expansion or variable
  1106.      substitution) in describing the arguments.  In Unix systems,
  1107.      you can control which shell is used with the `SHELL'
  1108.      environment variable. *Note Arguments::.
  1109.  
  1110. The environment.
  1111.      Your program normally inherits its environment from GDB, but you
  1112.      can use the GDB commands `set environment' and `unset
  1113.      environment' to change parts of the environment that will be
  1114.      given to the program.  *Note Environment::.
  1115.  
  1116. The working directory.
  1117.      Your program inherits its working directory from GDB.  You can
  1118.      set GDB's working directory with the `cd' command in GDB. 
  1119.      *Note Working Directory::.
  1120.  
  1121. The standard input and output.
  1122.      Your program normally uses the same device for standard input
  1123.      and standard output as GDB is using.  You can redirect input
  1124.      and output in the `run' command line, or you can use the `tty'
  1125.      command to set a different device for your program.  *Note
  1126.      Input/Output::.
  1127.  
  1128.      *Warning:* While input and output redirection work, you can't
  1129.      use pipes to pass the output of the program you're debugging to
  1130.      another program; if you attempt this, GDB is likely to wind up
  1131.      debugging the wrong program.
  1132.  
  1133.    When you issue the `run' command, your program begins to execute
  1134. immediately.  *Note Stopping::, for discussion of how to arrange for
  1135. your program to stop.  Once your program has been started by the
  1136. `run' command (and then stopped), you may evaluate expressions that
  1137. involve calls to functions in the inferior, using the `print' or
  1138. `call' commands.  *Note Data::.
  1139.  
  1140.    If the modification time of your symbol file has changed since the
  1141. last time GDB read its symbols, GDB will discard its symbol table
  1142. and re-read it.  In this process, it tries to retain your current
  1143. breakpoints.
  1144.  
  1145. 
  1146. File: gdb.info,  Node: Arguments,  Next: Environment,  Prev: Starting,  Up: Running
  1147.  
  1148. Your Program's Arguments
  1149. ========================
  1150.  
  1151.    The arguments to your program can be specified by the arguments of
  1152. the `run' command.  They are passed to a shell, which expands
  1153. wildcard characters and performs redirection of I/O, and thence to
  1154. the program.  GDB uses the shell indicated by your environment
  1155. variable
  1156. `SHELL' if it exists; otherwise, GDB uses `/bin/sh'.
  1157.  
  1158.    `run' with no arguments uses the same arguments used by the
  1159. previous `run', or those set by the `set args' command.
  1160.  
  1161. `set args'
  1162.      Specify the arguments to be used the next time your program is
  1163.      run.  If `set args' has no arguments, `run' will execute your
  1164.      program with no arguments.  Once you have run your program with
  1165.      arguments, using `set args' before the next `run' is the only
  1166.      way to run it again without arguments.
  1167.  
  1168. `show args'
  1169.      Show the arguments to give your program when it is started.
  1170.  
  1171. 
  1172. File: gdb.info,  Node: Environment,  Next: Working Directory,  Prev: Arguments,  Up: Running
  1173.  
  1174. Your Program's Environment
  1175. ==========================
  1176.  
  1177.    The "environment" consists of a set of environment variables and
  1178. their values.  Environment variables conventionally record such
  1179. things as your user name, your home directory, your terminal type,
  1180. and your search path for programs to run.  Usually you set up
  1181. environment variables with the shell and they are inherited by all
  1182. the other programs you run.  When debugging, it can be useful to try
  1183. running the program with a modified environment without having to
  1184. start GDB over again.
  1185.  
  1186. `path DIRECTORY'
  1187.      Add DIRECTORY to the front of the `PATH' environment variable
  1188.      (the search path for executables), for both GDB and your program.
  1189.      You may specify several directory names, separated by `:' or
  1190.      whitespace.  If DIRECTORY is already in the path, it is moved
  1191.      to the front, so it will be searched sooner.
  1192.  
  1193.      You can use the string `$cwd' to refer to whatever is the
  1194.      current working directory at the time GDB searches the path. 
  1195.      If you use `.' instead, it refers to the directory where you
  1196.      executed the `path' command.  GDB fills in the current path
  1197.      where needed in the DIRECTORY argument, before adding it to the
  1198.      search path.
  1199.  
  1200. `show paths'
  1201.      Display the list of search paths for executables (the `PATH'
  1202.      environment variable).
  1203.  
  1204. `show environment [VARNAME]'
  1205.      Print the value of environment variable VARNAME to be given to
  1206.      your program when it starts.  If you don't supply VARNAME,
  1207.      print the names and values of all environment variables to be
  1208.      given to your program.  You can abbreviate `environment' as
  1209.      `env'.
  1210.  
  1211. `set environment VARNAME [=] VALUE'
  1212.      Sets environment variable VARNAME to VALUE.  The value changes
  1213.      for your program only, not for GDB itself.  VALUE may be any
  1214.      string; the values of environment variables are just strings,
  1215.      and any interpretation is supplied by your program itself.  The
  1216.     
  1217.      VALUE parameter is optional; if it is eliminated, the variable
  1218.      is set to a null value.
  1219.  
  1220.      For example, this command:
  1221.  
  1222.           set env USER = foo
  1223.  
  1224.      tells a Unix program, when subsequently run, that its user is
  1225.      named `foo'.  (The spaces around `=' are used for clarity here;
  1226.      they are not actually required.)
  1227.  
  1228. `unset environment VARNAME'
  1229.      Remove variable VARNAME from the environment to be passed to
  1230.      your program.  This is different from `set env VARNAME =';
  1231.      `unset environment' removes the variable from the environment,
  1232.      rather than assigning it an empty value.
  1233.  
  1234. 
  1235. File: gdb.info,  Node: Working Directory,  Next: Input/Output,  Prev: Environment,  Up: Running
  1236.  
  1237. Your Program's Working Directory
  1238. ================================
  1239.  
  1240.    Each time you start your program with `run', it inherits its
  1241. working directory from the current working directory of GDB.  GDB's
  1242. working directory is initially whatever it inherited from its parent
  1243. process (typically the shell), but you can specify a new working
  1244. directory in GDB with the `cd' command.
  1245.  
  1246.    The GDB working directory also serves as a default for the
  1247. commands that specify files for GDB to operate on.  *Note Files::.
  1248.  
  1249. `cd DIRECTORY'
  1250.      Set GDB's working directory to DIRECTORY.
  1251.  
  1252. `pwd'
  1253.      Print GDB's working directory.
  1254.  
  1255. 
  1256. File: gdb.info,  Node: Input/Output,  Next: Attach,  Prev: Working Directory,  Up: Running
  1257.  
  1258. Your Program's Input and Output
  1259. ===============================
  1260.  
  1261.    By default, the program you run under GDB does input and output to
  1262. the same terminal that GDB uses.  GDB switches the terminal to its
  1263. own terminal modes to interact with you, but it records the terminal
  1264. modes your program was using and switches back to them when you
  1265. continue running your program.
  1266.  
  1267. `info terminal'
  1268.      Displays GDB's recorded information about the terminal modes
  1269.      your program is using.
  1270.  
  1271.    You can redirect the program's input and/or output using shell
  1272. redirection with the `run' command.  For example,
  1273.  
  1274.      run > outfile
  1275.  
  1276. starts the program, diverting its output to the file `outfile'.
  1277.  
  1278.    Another way to specify where the program should do input and
  1279. output is with the `tty' command.  This command accepts a file name
  1280. as argument, and causes this file to be the default for future `run'
  1281. commands.  It also resets the controlling terminal for the child
  1282. process, for future `run' commands.  For example,
  1283.  
  1284.      tty /dev/ttyb
  1285.  
  1286. directs that processes started with subsequent `run' commands default
  1287. to do input and output on the terminal `/dev/ttyb' and have that as
  1288. their controlling terminal.
  1289.  
  1290.    An explicit redirection in `run' overrides the `tty' command's
  1291. effect on the input/output device, but not its effect on the
  1292. controlling terminal.
  1293.  
  1294.    When you use the `tty' command or redirect input in the `run'
  1295. command, only the input *for your program* is affected.  The input
  1296. for GDB still comes from your terminal.
  1297.  
  1298. 
  1299. File: gdb.info,  Node: Attach,  Next: Kill Process,  Prev: Input/Output,  Up: Running
  1300.  
  1301. Debugging an Already-Running Process
  1302. ====================================
  1303.  
  1304. `attach PROCESS-ID'
  1305.      This command attaches to a running process--one that was started
  1306.      outside GDB.  (`info files' will show your active targets.) 
  1307.      The command takes as argument a process ID.  The usual way to
  1308.      find out the process-id of a Unix process is with the `ps'
  1309.      utility, or with the `jobs -l' shell command.
  1310.  
  1311.      `attach' will not repeat if you press RET a second time after
  1312.      executing the command.
  1313.  
  1314.    To use `attach', you must be debugging in an environment which
  1315. supports processes.  You must also have permission to send the
  1316. process a signal, and it must have the same effective user ID as the
  1317. GDB process.
  1318.  
  1319.    When using `attach', you should first use the `file' command to
  1320. specify the program running in the process and load its symbol table.
  1321. *Note Files::.
  1322.  
  1323.    The first thing GDB does after arranging to debug the specified
  1324. process is to stop it.  You can examine and modify an attached
  1325. process with all the GDB commands that are ordinarily available when
  1326. you start processes with `run'.  You can insert breakpoints; you can
  1327. step and continue; you can modify storage.  If you would rather the
  1328. process continue running, you may use the `continue' command after
  1329. attaching GDB to the process.
  1330.  
  1331. `detach'
  1332.      When you have finished debugging the attached process, you can
  1333.      use the `detach' command to release it from GDB's control. 
  1334.      Detaching the process continues its execution.  After the
  1335.      `detach' command, that process and GDB become completely
  1336.      independent once more, and you are ready to `attach' another
  1337.      process or start one with `run'.  `detach' will not repeat if
  1338.      you press RET again after executing the command.
  1339.  
  1340.    If you exit GDB or use the `run' command while you have an
  1341. attached process, you kill that process.  By default, you will be
  1342. asked
  1343. for confirmation if you try to do either of these things; you can
  1344. control whether or not you need to confirm by using the `set
  1345. confirm' command (*note Messages/Warnings::.).
  1346.  
  1347.